package com.springcloud.eshop.aggrdata.rabbitmq.factory;

import com.springcloud.eshop.aggrdata.rabbitmq.strategy.BaseAggrDataChangeHandler;

import java.util.HashMap;
import java.util.Map;

/**
 * @Desc:
 * @Date: 2020-07-02
 * @Version:v1.0
 */
public class AggrDataChangeHandlerFactory {

    private static volatile Map<String, BaseAggrDataChangeHandler> baseAggrDataChangeHandlerHashMap = new HashMap<>();

    public static boolean register(String type, BaseAggrDataChangeHandler baseAggrDataChangeHandler) {
        baseAggrDataChangeHandlerHashMap.put(type, baseAggrDataChangeHandler);
        return true;
    }

    /**
     * @Desc: 获取指定数据变更处理器
     * @Param type
     * @Return com.springcloud.eshop.aggrdata.rabbitmq.strategy.BaseAggrDataChangeHandler
     * @Date: 2020/7/2
     */
    public static BaseAggrDataChangeHandler getDataChangeHandler(String type) {
        return baseAggrDataChangeHandlerHashMap.get(type);
    }
}
